home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
PASCAL
/
0189.ZIP
/
PICTOFRM.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1986-02-09
|
11KB
|
302 lines
(***************************************************************)
(* *)
(* FILER A LA PASCAL DATA BASE SOURCE CODE FILE *)
(* *)
(* (C) 1985 by John M. Harlan *)
(* 24000 Telegraph *)
(* Southfield, MI. 48034 *)
(* *)
(* The FILER GROUP of programs is released on a "FREE *)
(* SOFTWARE" basis. The recipient is free to examine *)
(* and use the software with the understanding that if *)
(* the FILER GROUP of programs prove to be of use and *)
(* value, a contribution to the author is encouraged. *)
(* *)
(* While reasonable effort has been made to ensure the *)
(* reliability of the FILER GROUP of programs, no war- *)
(* ranty is given. The recipient uses the programs at *)
(* his own risk and in no event shall the author be *)
(* liable for damages arising from their use. *)
(* *)
(* *)
(***************************************************************)
program pictofrm; { ONE OF THE FILER GROUP OF PROGRAMS }
{ CONVERTS PICTURE OF DATA BASE SCREEN TO XXX.FRM FILE }
{ PICTOFRM.PAS VERSION 2.0 }
{ MAY 20, 1985 }
{ Formatted 2/7/86 by Doug Stevens using Pformat and the Turbo
editors global search/replace. Original version was 100%
upper case and very hard to read. }
label QUIT;
type
NameStr = string[12];
String79 = string[79];
var
x : integer; { POSITION IN SCREEN DATA LINE }
y : integer; { LABEL & DATA ARRAY NUMBER }
z : integer; { SCREEN LINE COUNTER }
w, pointer, labelstart,
labelend, datastart,dataend,
decpointer,wholedigits,
wholeend, commas, lastline,
arraycount, blockingfactor : integer;
lab, data,
ascii, fileexists : boolean;
line : array [1..30] of String79;
work : array [1..79] of char;
info : String79;
labelname : String79;
filename : string[12];
ch : char;
labellength, datalen,dataform,
row,column : array[1..32] of integer;
lblname : array[1..32] of String79;
source, screenform : text;
{===============================================================}
{ FUNCTION EXIST }
{===============================================================}
function Exist(filename : NameStr) : boolean;
var
fil : file;
status : Integer;
begin
Assign(fil,filename);
{$I-}
reset(fil);
{$I+}
Exist := (IOResult = 0);
{$I-} Close(fil); status := IOResult; {$I+} (* Required by Turbo 3.x *)
end; (* Added by Doug Stevens *)
{===============================================================}
{ STORE LABEL & DATA PROCEDURE }
{===============================================================}
procedure StoreLabDat;
begin
data := false;
lab := false;
lblname[y] := labelname; { SAVE LABEL IN ARRAY }
if decpointer = 0 then { NO DECIMAL POINT IN NUMBER }
begin
wholeend := dataend;
decpointer := dataend ;
end;
if ascii = true then { ASCII DATA FOUND }
begin
dataform[y] := 15;
commas := 0;
end
else
begin { PROCESS FOR NUMERIC DATA ONLY }
dataform[y] := dataend-decpointer;
wholedigits := wholeend - datastart;
if wholedigits > 7 then commas := 2
else
begin
if wholedigits >3 then commas := 1 else commas := 0;
end;
end; { IF ASCII...ELSE BEGIN }
datalen[y] := dataend - datastart + 1 - commas;
row[y] := z;
column[y] := labelstart;
y := y + 1; { INCREMENT ARRAY COUNTER }
dataend := 0;
datastart := 0;
decpointer := 0;
labelname := '';
ascii := false;
end;
{===============================================================}
{ MAIN PROGRAM }
{===============================================================}
begin
repeat
ClrScr;
GotoXY(1,24);
writeln('"PICTOFRM" CONVERTS FILES FROM XXX.PIC TO XXX.FRM');
writeln;
write('ENTER FILENAME OF PICTURE FILE : ');
readln(filename);
x := pos('.',filename);
if x <> 0 then filename := copy(filename,1,x-1);
if filename = 'END' then goto QUIT; { Quick and dirty exit. }
filename := filename + '.PIC';
fileexists := Exist(filename);
until fileexists = true;
Assign (source,filename);
reset(source);
z := 1; { LINE NUMBER IN SCREEN }
ClrScr;
while not eof(source) do
begin
readln(source,line[z]);
writeln(line[z]);
z := z+1;
end;
lastline := z-1;
write('ENTER ANY KEY TO CONTINUE ');
read(Kbd,ch);
DelLine;
writeln;
{===============================================================}
{ TRANSLATE SCREEN DATA }
{===============================================================}
y := 1; { ARRAY COUNTER }
z := 1; { SCREEN LINE COUNTER }
while z <= lastline do
begin
datastart := 0;
dataend := 0;
decpointer := 0;
lab := false;
data := false;
labelname := '';
ascii := false;
for x := 1 to length(line[z]) do
begin
if lab = false then
begin
if line[z][x] <> ' ' then
begin
labelstart := x;
lab := true; { FIRST CHAR OF LABEL FOUND }
labelname := labelname + line[z][x];
end;
end
else
begin { LAB = TRUE}
if data = false then { PROCESS LABEL INFO }
begin { LAB = TRUE & DATA = FALSE }
if line[z][x] = ':' then
begin
data := true;
end
else { WE HAVE ANOTHER CHAR OF LABEL }
begin
labelname := labelname + line[z][x];
end;
end
else { LAB = TRUE & DATA = TRUE }
begin { PROCESS NUMERIC INFORMATION }
if datastart = 0 then
begin
if line[z][x] <> ' ' then
begin
datastart := x;
if UpCase(line[z][x]) in ['A'..'Z'] then ascii := true;
if line[z][x] = '.' then
begin
decpointer := x;
wholeend := x-1;
end;
end;
end
else
begin
if x = length(line[z]) then
begin
dataend := x;
StoreLabDat; { END OF LINE FOUND }
end
else
begin
if line[z][x] = '.' then
begin
decpointer := x;
wholeend := x-1;
end;
if line[z][x] = ' ' then
begin
dataend := x-1;
StoreLabDat; { SPACE AFTER LABEL FOUND }
end;
end; { IF X .. ELSE BEGIN }
end; { IF DATASTART .. ELSE BEGIN }
end; { IF DATA ... ELSE BEGIN }
end; { IF LAB ... ELSE BEGIN }
end; { FOR X ... BEGIN }
z := z + 1;
end; { WHILE .. BEGIN }
close(source);
x := pos('.',filename);
if x <> 0 then filename := copy(filename,1,x-1);
filename := filename + '.FRM';
Assign(screenform,filename);
rewrite(screenform);
arraycount := y-1;
for x := 1 to y-1 do
begin
str(row[x]:3,info);
write (screenform,'ROW',info);
write ('ROW',info);
str(column[x]:3,info);
write (screenform,', COL',info);
write (', COL',info);
str(dataform[x]:3,info);
write (screenform,', FORM',info);
write (', FORM',info);
str(datalen[x]:4,info);
write (screenform,', LEN',info);
write (', LEN',info);
write (screenform,', MISC ___');
write (', MISC ___');
writeln (screenform,', LABEL >',lblname[x],'<');
writeln (', LABEL >',lblname[x],'<');
end;
writeln;
write('ENTER ANY KEY TO CONTINUE ');
read(Kbd,ch);
DelLine;
writeln;
writeln('BEGINNING WITH A PICTURE OF THE FILE, "PICTOFRM" HAS TRANSLATED');
writeln('THIS INFORMATION INTO AN INTERMEDIATE FORM AND STORED IT IN A');
writeln('FILE WITH THE SAME NAME AND THE FILE EXTENSION ".FRM".');
writeln;
writeln('THIS FILE MAY NOW BE EDITED WITH ANY EDITOR SUCH AS WORDSTAR');
writeln('TO REVISE THE ORDER OF THE FIELDS WITHIN THE FILE.');
writeln;
writeln('FINALLY, TO CONVERT THE ".FRM" INTERMEDIATE FILE INTO A ".DAT"');
writeln('FILE THAT CAN BE USED BY THE FILER GROUP OF PROGRAMS, USE THE');
writeln('PROGRAM "FRMTODAT".');
z := 0;
for x :=1 to arraycount do
z := z + datalen[x];
writeln;
writeln('RECORD LENGTH : ',z,' BYTES');
blockingfactor := 256 div z;
writeln('BLOCKING FACTOR : ',blockingfactor);
w := 256 div (blockingfactor + 1) -z;
writeln('BYTES LEFT IN BLOCK : ',256-z*blockingfactor);
write('CHANGE RECORD LENGTH BY ',w);
writeln(' BYTES TO INCREASE BLOCKING FACTOR');
close(screenform);
QUIT:
end.